{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 案例1，对象建立时初始化变量，实例化对象时要传参\n",
    "class Imcn:\n",
    "    def __init__(self, a, b, c):\n",
    "        self.a = a\n",
    "        self.b = b\n",
    "        self.c = c\n",
    "\n",
    "    def xsum(self):\n",
    "        return self.a + self.b + self.c\n",
    "    \n",
    "    def xmb(self):\n",
    "        return self.a * self.b * self.c\n",
    "    \n",
    "def xplus(number):\n",
    "    a = 0\n",
    "    for i in range(1,number):\n",
    "        a = i + 1\n",
    "    return a"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "xiaoxiao = Imcn(1,2,3)  # 实例化的时候就需要传参，函数不传参\n",
    "xiaoxiao.xsum() # 使用函数时不传参"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 案例1，对象建立时没有初始化变量，函数引用时要传参\n",
    "class Summer:\n",
    "    def wu(self,cs):\n",
    "        return cs * 10"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [],
   "source": [
    "xiaoxiao = Summer()     # 实例化的时候不需要传参，调用函数传参\n",
    "xiaoxiao.wu(50) "
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
